/* eslint-disable @typescript-eslint/no-explicit-any */
// 使用 RTK 来构建 store
import { configureStore, createSlice } from '@reduxjs/toolkit'
import { componentsData } from './data'


const initialState = {
    componentsData: componentsData,
    componentList: [],
    currentKey:null,
    currentcomponent: null,
    menuInfo:{
        showMenu:false,
        menuLeft:120,
        menuTop:0,
    },
    showMenu: false,
    menuLeft: 120,
    menuTop: 0,
    color: {
        r: 255, g: 255, b: 255, a: 1.0
    }
}
const studentSlice = createSlice({
    name: "stu",
    initialState,
    reducers: {
        addTiem(state: any, { payload }) {
            state.componentList.push(payload);
            console.log(state, payload, 'papappapappa')
        },
        styleTime(state: any, { payload }) {
            const a = state.componentList[payload.id]
            a.style = { ...a.style, ...payload.style }
            console.log(state, payload, 'ststststtydtya')
        },
        //显示右击
       isShowMenu(state:any,{payload}){
        state.menuInfo = {...payload}
       },
       //设置当前点击的元素
       setCurrentKey(state:any,{payload}){
        state.currentKey = payload
       }
    }
})
const store = configureStore({
    reducer: {
        student: studentSlice.reducer
    }
})
export const { addTiem, styleTime, isShowMenu,setCurrentKey } = studentSlice.actions

export default store
